package com.springboot.demo.config;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class AdminLoginInterceptor implements HandlerInterceptor{
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        Object admin = request.getSession().getAttribute("phonenumber");
        if(admin == null){
            request.getRequestDispatcher("/Librarian_login.html").forward(request,response);
        return false;
        }
        return true;
    }
}
